

####################################################
####          Replication Code for              ####
####     Spatial Interdependence                ####
####     and Instrumental Variable Models       ####
####################################################
####                                            ####
####                9/ 06/2018                  ####
####  this file runs rcode to create Figure 1   ####
####                                            ####
####################################################









### load data with journal statistics
data <- read.csv("Data_Figure1.csv")


### generate plot
p = ggplot(data = data,aes(y = Dif, x = Year, colour = Variable, fill = Variable,  width=.5))
p = p +  geom_col(size = 1.8)
p = p + theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
p = p + labs(title = "", y="Articles with IV estimators", x = "Year")+ theme(axis.text.x=element_text(size=13)) + theme(axis.text.y=element_text(size=15))+ theme(axis.title.x = element_text(size = 20),axis.title.y = element_text(size = 20))
p = p  + scale_x_continuous(name = "Year", breaks = c(2000, 2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016))
p = p + scale_colour_grey(name = "") +  scale_fill_grey(name = "")
p = p + theme(legend.position = c(0.24, 0.82), legend.direction = "vertical", legend.key = element_blank(), legend.background = element_rect(colour = "white"), legend.text = element_text(size = 12), legend.title = element_text(size = 10), panel.border = element_rect(colour = "black", fill=NA, size=4))
                                        #p = p + geom_point(data = share_dat, x = Year, y = share )
p = p + geom_text(aes(y = Count, label=Count), vjust=1.6, color="white", size=4)
plot(p)
### save plot
ggsave("Figure1.pdf")

